package com.gimi.cloud.jimi.commonService.service.impl;

import com.gimi.cloud.jimi.commonService.service.CoreApiLogService;
import com.gimi.cloud.jimi.dao.dao.userInfo.ApiLogDao;
import com.gimi.cloud.jimi.entity.core.ApiLog;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("coreApiLogService")
public class CoreApiLogServiceImpl implements CoreApiLogService {
	
	 @Autowired
	 private ApiLogDao apiLogDao;


	@Override
	public ApiLog addApiLog(ApiLog apiLog) {
		apiLogDao.insertUseGeneratedKeys(apiLog);
		return apiLog;
	}

	@Override
	public void updateLogTimes(long configId, boolean success) {
		if(success){
    		apiLogDao.updateBySql("UPDATE sys_api_config SET post_time = post_time+1,suceess_time = suceess_time +1 WHERE id ="	+ configId);
    	}else{
    		apiLogDao.updateBySql("UPDATE sys_api_config SET post_time = post_time+1 WHERE id =" + configId);
    	}
	}

}
